Add EasyGPS binary format based on info from Eric Cloninger.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 14 May 2003 18:50:27 +0000 (18:50 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 14 May 2003 18:50:27 +0000 (18:50 +0000)
gpsbabel/Makefile
gpsbabel/README
gpsbabel/reference/easygps.loc [new file with mode: 0755]
gpsbabel/testo
gpsbabel/util.c
gpsbabel/vecs.c

index 2eb64295febaa1bfa06ae3d2ed069dd33fd42f17..ec7bcef8a2c7021c0689111849288c76c9932fea 100644 (file)
@@ -5,7 +5,7 @@ INSTALL_TARGETDIR=/usr/local/
 FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o \
        gpsutil.o pcx.o cetus.o copilot.o gpspilot.o magnav.o \
        psp.o holux.o garmin.o tmpro.o tpg.o \
-       xcsv.o gcdb.o tiger.o internal_styles.o
+       xcsv.o gcdb.o tiger.o internal_styles.o easygps.o
 
 FILTERS=position.o duplicate.o
 
@@ -55,8 +55,8 @@ dep:
        (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e "\t./mkstyle.sh > internal_styles.c" ) >> /tmp/dep
        echo Edit Makefile and bring in /tmp/dep
 
-VERSIONU=1_1_1_beta00508003
-VERSIOND=1.1.1_beta00508003
+VERSIONU=1_1_1_beta00514003
+VERSIOND=1.1.1_beta00514003
 release:
        rm -fr gpsbabel-$(VERSIOND)
        cvs tag gpsbabel_$(VERSIONU)
index 16f006a53205e68cbe3b9d51abd3d8eaf9f2a213..0fdaae59354216f863911539d79c6500bed93a1e 100644 (file)
@@ -305,6 +305,18 @@ THE FORMATS
        http://xcski.com/~ptomblin/CoPilot/
        http://navaid.com/CoPilot/
 
+    EasyGPS
+
+        This is the binary file format used by EasyGPS.  This format is
+        seemingly being phased out in favor of GPX in newer versions of
+        EasyGPS, but this allows conversions to and from the old binary
+        .loc format.
+
+       http://www.easygps.com/
+
+        Information about and sketchy code to implement this file format
+        were provided by Eric Cloninger.
+
 
 DATA FILTERS
 
diff --git a/gpsbabel/reference/easygps.loc b/gpsbabel/reference/easygps.loc
new file mode 100755 (executable)
index 0000000..011dd96
Binary files /dev/null and b/gpsbabel/reference/easygps.loc differ
index 4c218bb8facfdf85fd96a650f88295325ad13c57..cdfc4cd19efb2b5c540e69baadefd1854087c775 100755 (executable)
@@ -291,3 +291,12 @@ ${PNAME} -i copilot -f reference/UKultralight.pdb -o copilot -F ${TMPDIR}/cop.pd
 ${PNAME} -i copilot -f reference/UKultralight.pdb -o gpx -F ${TMPDIR}/cop1.gpx
 ${PNAME} -i copilot -f ${TMPDIR}/cop.pdb -o gpx -F ${TMPDIR}/cop2.gpx
 compare ${TMPDIR}/cop1.gpx ${TMPDIR}/cop2.gpx
+
+#
+# EasyGPS.   Another binary format.
+#
+rm -f ${TMPDIR}/easy.loc
+${PNAME} -i easygps -f reference/easygps.loc -o easygps -F ${TMPDIR}/ez.loc
+${PNAME} -i easygps -f reference/easygps.loc -o gpx -F ${TMPDIR}/ez1.gpx
+${PNAME} -i easygps -f ${TMPDIR}/ez.loc -o gpx -F ${TMPDIR}/ez2.gpx
+compare ${TMPDIR}/ez1.gpx ${TMPDIR}/ez2.gpx
index 359e6f2c2d6486b0e42499f093380b56b56d81a8..d67de406358c81cc18caf73b5e7946836f203aa9 100644 (file)
@@ -24,6 +24,9 @@
 #include <stdlib.h>
 #include <ctype.h>
 
+static int i_am_little_endian = -1;
+static int doswap(void);
+
 #ifdef DEBUG_MEM
 #define DEBUG_FILENAME "/tmp/gpsbabel.debug"
 
@@ -173,7 +176,20 @@ xstrappend(char *src, const char *new)
        return src;
 }
 
+/* 
+ * Duplicate a pascal string into a normal C string.
+ */
+char *
+pstrdup(char *src)
+{
+       int len = src[0];
+       char *obuf = xmalloc(len + 1);
 
+       memcpy(obuf, src + 1, len);
+       obuf[len] = 0;
+
+       return obuf;
+}
 
 void 
 rtrim(char *s)
@@ -296,6 +312,28 @@ le_read32(void *addr)
        return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
 }
 
+/*
+ *  Read a little-endian 64-bit value from 'src' and return it in 'dest' 
+ *  in host endianness.
+ */
+void
+le_read64(void *dest, void *src)
+{
+       char *cdest = dest;
+       char *csrc = src;
+
+       doswap(); /* make sure i_am_little_endian is initialized */
+
+       if (i_am_little_endian) {
+               memcpy(dest, src, 8);
+       } else {
+               int i;
+               for (i = 0; i < 7; i++) {
+                       cdest[i] = csrc[7-i];
+               }
+       }
+}
+
 void
 le_write16(void *addr, unsigned value)
 {
@@ -373,11 +411,9 @@ get_cache_icon(const waypoint *waypointp)
        return NULL;
 }
 
-static int swapit = -1;
-
 static int doswap()
 {
-  if (swapit < 0)
+  if (i_am_little_endian < 0)
   {
        /*      On Intel, Vax and MIPs little endian, -1.0 maps to the bytes
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f and on Motorola,
@@ -387,9 +423,9 @@ static int doswap()
        double d = 1.0;
        char c[8];
        memcpy(c, &d, 8);
-       swapit = (c[0] == 0);
+       i_am_little_endian = (c[0] == 0);
   }
-  return swapit;
+  return i_am_little_endian;
 }
 
 double
@@ -398,10 +434,10 @@ pdb_read_double(void* ptr)
   double ret;
   char r[8];
   int i;
-  doswap(); /* make sure swapit is initialized */
+  doswap(); /* make sure i_am_little_endian is initialized */
   for (i = 0; i < 8; i++)
   {
-       int j = (swapit)?(7-i):i;
+       int j = (i_am_little_endian)?(7-i):i;
        r[i] = ((char*)ptr)[j];
   }
   memcpy(&ret, r, 8);
@@ -415,10 +451,10 @@ pdb_write_double(void* ptr, double d)
   int i;
 
   memcpy(r, &d, 8);
-  doswap(); /* make sure swapit is initialized */
+  doswap(); /* make sure i_am_little_endian is initialized */
   for (i = 0; i < 8; i++)
   {
-       int j = (swapit)?(7-i):i;
+       int j = (i_am_little_endian)?(7-i):i;
        *(char*)ptr++ = r[j];
   }
   return;
index 9540dcc7089fa1da2739e73f45203ae12e4719c8..26ba02fb82c2fe3319cb849e8d60c29c58603c57 100644 (file)
@@ -49,6 +49,7 @@ extern ff_vecs_t tpg_vecs;
 extern ff_vecs_t magnav_vec;
 extern ff_vecs_t tmpro_vecs;
 extern ff_vecs_t gcdb_vecs;
+extern ff_vecs_t easygps_vecs;
 
 static
 vecs_t vec_list[] = {
@@ -167,6 +168,12 @@ vecs_t vec_list[] = {
                "U.S. Census Bureau Tiger Mapping Service",
                NULL
        },
+       {
+               &easygps_vecs,
+               "easygps",
+               "EasyGPS",
+               NULL
+       },
        {
                NULL,
                NULL,